<?php
namespace Profile\Controller;
use Profile\Controller\BaseController;
class ScoresController extends BaseController {
	private $tbl;
	public function _initialize(){
		$this->tbl='scores';
		$this->model=D($this->tbl);
		$this->id=$_SESSION['user']['id'];
		parent::_initialize();
	}
    public function index(){
		$sql="select * from dingdandet where uid='{$_SESSION['user']['id']}' and isping=0 order by id desc";
		$res=M()->query($sql);
		//var_dump($res);exit;
		$this->assign("list",$res);
		$this->display();
		
    }
	public function form(){
		$data=I('get.');
		//var_dump($data);exit;
		$this->assign("data",$data);
		$this->display();
	}
	public function add(){
		$did=I('post.dingid');
		$sql="update dingdandet set isping=1 where id='{$did}'";
		//echo $sql;exit;
		M()->execute($sql);
		parent::add($this->tbl,"pic",0);
	}
	public function	view(){
		$id=I('get.id');//获取id
	}
	public function delete(){//删除
		parent::delete($this->tbl,"id","pic");
	}
	public function search(){
		$key=I('post.searchname');
		$sql="select * from scores inner join video inner join users on 
		scores.vid=video.id and scores.uid=users.id  where scores.score like '%".$key."%'
		 or video.videoname like '%".$key."%' or users.uname like '%".$key."%' order by scores.id desc";
		$res=M()->query($sql);
		$this->assign("list",$res);
		$this->display();
	}
}